Repository navigation
Stop false storage-degraded banners under audit read load - #63
Merged
Merged
Conversation
Audit reads (ticket/dashboard/logs/storage) now run on fresh read-only WAL connections instead of queueing on the 250ms write lock, so parallel dashboard views no longer starve live record_request commits or each other. Lock-contention timeouts are reported as transient_contention and never latch the 24h degraded banner; only real storage errors do. The dashboard P95 scan moves to SQL (COUNT + ORDER BY OFFSET) over a new covered (started_at, duration_ms) index (schema v4, backfilled once from payloads), replacing the per-row json_extract fetchall that serialized 300k-row scans through Python. /admin/storage keeps reporting the full health payload with degraded flags instead of 503, so the storage page diagnostics stay visible during degradation.
|
Sorry @maiphucgiang, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 2 days and 23 hours by commenting |
Reviewer's GuideThe PR decouples audit reads from the write lock using read-only WAL snapshots, classifies lock contention as non-degrading transient health telemetry, accelerates dashboard P95 through a migrated indexed duration column, and keeps storage diagnostics available during degradation. Sequence diagram for non-blocking audit reads and request recordingsequenceDiagram
participant WebUI
participant AuditStore
participant ReadDB as ReadOnlyWAL
participant WriteDB as WriteConnection
participant SQLite
par Dashboard read
WebUI->>AuditStore: dashboard()
AuditStore->>ReadDB: _open_read()
ReadDB->>SQLite: SELECT dashboard data
SQLite-->>ReadDB: dashboard result
ReadDB-->>AuditStore: return result
and Request commit
WebUI->>AuditStore: record_request(record)
AuditStore->>WriteDB: _run(commit, write=True)
WriteDB->>SQLite: BEGIN IMMEDIATE and INSERT
SQLite-->>WriteDB: commit result
WriteDB-->>AuditStore: recorded result
end
Entity relationship diagram for schema v4 duration indexingerDiagram
REQUESTS {
text id PK
real started_at
real duration_ms
text payload
}
REQUESTS }o--|| REQUESTS_DURATION_INDEX : covered_by
State diagram for storage health and transient contentionstateDiagram-v2
[*] --> Healthy
Healthy --> TransientContention: TimeoutError / _fault
TransientContention --> Healthy: transient window expires
Healthy --> Degraded: sqlite.Error or OSError / _fault
TransientContention --> Degraded: real storage error
Degraded --> Healthy: degraded window expires
state TransientContention {
[*] --> Reported
Reported: transient_contention
Reported: transient_count
}
state Degraded {
[*] --> Latched
Latched: degraded=true
Latched: recent_failures
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
A transient prune timeout during the concurrent mix is permitted by design; the contract under test is zero dropped records and no degraded latch.
Add zh/en labels and value mappings for storage_archive, credentials.uploaded/exported, session.revoke_failed, and the credential.auto_checkin/auto_travel settings events.
Replace the small header icon button with a full-width pill bar pinned to the sidebar bottom (label plus panel icon, icon-only when collapsed), matching the existing glass panel styling.
On narrow screens the collapsed state now hides the brand row and nav strip entirely, leaving the labeled expand bar as the only remnant instead of an icon-only nav. Also apply vp check formatting to the recent sidebar and label edits.
The collapsed mobile sidebar now hides the nav strip behind the expand bar; the test expands it before navigating and asserts the stow.
Maintenance results, preference notices, busy state and errors now render at the top of the credential drawer while it is open, instead of behind the overlay on the main page; the page-level copies return when the drawer closes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
record_requestcommits or each other.transient_contention(1h window + lifetime count) and never latch the 24h degraded banner; only real storage errors (sqlite/OSError) latch.COUNT+ORDER BY OFFSET) over a new covered(started_at, duration_ms)index; schema v4 adds the column with a one-time backfill from payloads, replacing the per-rowjson_extractPython fetchall./admin/storagereturns the full health payload withdegradedflags instead of 503, so storage-page diagnostics stay visible during degradation; page-open bounded prune slice is preserved.Validation
tests/test_audit_store.py40/40; full backend suite (per-filepython -B tests/test_*.py) all exit 0; web vitest 17 files / 146 tests passed.TimeoutError, 7/80 audit records dropped, degraded latched 24h; after — zero faults, zero drops,degraded=false./v1/chat/completionsrecorded end-to-end, no degradation. Live instance migrated v3→v4 automatically (10160/10160 rows backfilled).Summary by Sourcery
Prevent audit read workloads from triggering false storage degradation while improving dashboard query performance and storage diagnostics.
New Features:
Bug Fixes:
Enhancements:
Tests: